﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Novel.Common;
using Novel.DAL.Base;

namespace Novel.Factory
{
    public sealed class DataFactory
    {
        private static readonly string path = "Novel.DAL";//System.Configuration.ConfigurationManager.AppSettings["Enter.DataProxy.Mail"];

        private static object CreateObject(string path, string CacheKey)
        {
            object objType = CacheHelper.Get(CacheKey);
            if (objType == null)
            {
                try
                {
                    objType = Assembly.Load(path).CreateInstance(CacheKey);
                    CacheHelper.Set(CacheKey, objType);
                }
                catch { }

            }
            return objType;
        }
        


        /// <summary>
        /// 通过反射机制，实例化T_001GatherTask接口对象。
        /// </summary>
        ///<returns>T_001GatherTask接口对象</returns>
        public static IT_001GatherTaskManager Create_T_001GatherTask()
        {
            string CacheKey = path + ".T_001GatherTaskManager";
            object objType = CreateObject(path, CacheKey);
            return (IT_001GatherTaskManager)objType;
        }


        /// <summary>
        /// 通过反射机制，实例化T_002BookGatherUrl接口对象。
        /// </summary>
        ///<returns>T_002BookGatherUrl接口对象</returns>
        public static IT_002BookGatherUrlManager Create_T_002BookGatherUrl()
        {
            string CacheKey = path + ".T_002BookGatherUrlManager";
            object objType = CreateObject(path, CacheKey);
            return (IT_002BookGatherUrlManager)objType;
        }


        /// <summary>
        /// 通过反射机制，实例化T_003Novel_Types接口对象。
        /// </summary>
        ///<returns>T_003Novel_Types接口对象</returns>
        public static IT_003Novel_TypesManager Create_T_003Novel_Types()
        {
            string CacheKey = path + ".T_003Novel_TypesManager";
            object objType = CreateObject(path, CacheKey);
            return (IT_003Novel_TypesManager)objType;
        }


        /// <summary>
        /// 通过反射机制，实例化T_004Novel接口对象。
        /// </summary>
        ///<returns>T_004Novel接口对象</returns>
        public static IT_004NovelManager Create_T_004Novel()
        {
            string CacheKey = path + ".T_004NovelManager";
            object objType = CreateObject(path, CacheKey);
            return (IT_004NovelManager)objType;
        }


        /// <summary>
        /// 通过反射机制，实例化T_005NovelInfo接口对象。
        /// </summary>
        ///<returns>T_005NovelInfo接口对象</returns>
        public static IT_005NovelInfoManager Create_T_005NovelInfo()
        {
            string CacheKey = path + ".T_005NovelInfoManager";
            object objType = CreateObject(path, CacheKey);
            return (IT_005NovelInfoManager)objType;
        }


        /// <summary>
        /// 通过反射机制，实例化T_006Novel_Chapter接口对象。
        /// </summary>
        ///<returns>T_006Novel_Chapter接口对象</returns>
        public static INovel_ChapterManager Create_Novel_Chapter()
        {
            string CacheKey = path + ".INovel_ChapterManager";
            object objType = CreateObject(path, CacheKey);
            return (INovel_ChapterManager)objType;
        }
       
    }
}


























  